package com.zuimei.zuimei.utils;

import android.app.Activity;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.zuimei.zuimei.R;

/**
 * Created by Jogger on 2017/1/30.
 * 侧边栏
 */

public class SlidingMenuUtil {
    private static SlidingMenu mMenu;
    private static SlidingMenuUtil mSlidingMenuUtil;

    private SlidingMenuUtil() {
    }

    public static SlidingMenuUtil getInstance() {
        if (mSlidingMenuUtil == null) {
            mSlidingMenuUtil = new SlidingMenuUtil();
        }
        return mSlidingMenuUtil;
    }

    public void initSlidingMenu(Activity activity) {
        mMenu = new SlidingMenu(activity);
        mMenu.setMode(SlidingMenu.LEFT);//位置
        mMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);//触摸模式
//            menu.setShadowWidthRes(R.dimen.shadow_width);
//            menu.setShadowDrawable(R.drawable.shadow);
        mMenu.setBehindOffset(100); // 设置滑动菜单视图的宽度
        mMenu.setFadeDegree(0.35f); // 设置渐入渐出效果的值
        mMenu.attachToActivity(activity, SlidingMenu.SLIDING_CONTENT, true);//true:设置沉浸
        mMenu.setMenu(R.layout.left_menu);
    }

    public SlidingMenu getSlideMenu(Activity activity) {
        if (mMenu != null) {
            return mMenu;
        } else {
            initSlidingMenu(activity);
            return getSlideMenu(activity);
        }
    }
}
